#ifndef MYMOUSEBUTTON_H
#define MYMOUSEBUTTON_H

#include <QPushButton>

//老鼠按钮类
class QTimer;

class MyMouseButton : public QPushButton
{
    Q_OBJECT
public:
    explicit MyMouseButton(QWidget *parent = nullptr);
    //设置老鼠类型
    //@param type 类型
    void setMouseType(int type);
    //激活老鼠
    void mouseActive();
    //获取老鼠状态
    //@return bool 老鼠状态
    bool mouseIsActive();
    //获取老鼠的类型
    //@return int 类型
    int getMouseType();
    //击打老鼠
    void hitMouse();
    //老鼠消失
    void mouseHide();
    //老鼠暂停
    void mousePause();
    //暂停恢复
    void mouseStart();
    //获取老鼠是否被击打
    bool getMouseIsClicked();

protected slots:
    //老鼠动画定时器槽函数，刷新老鼠位置
    void mouseMoveTimerTimeoutSlot();

protected:
    //绘图事件
    void paintEvent(QPaintEvent *);
    //鼠标事件
    void mousePressEvent(QMouseEvent *);
    void mouseReleaseEvent(QMouseEvent *);
    void mouseMoveEvent(QMouseEvent *);

    int iMouseY = 80;                   //老鼠的位置
    int iMouseType = 0;                 //老鼠的类型
    int iMouseDirection = 0;            //老鼠运动的方向
                                        //0 - up 1 - down
    int iMouseMoveSpeed = 2;            //老鼠移动的速度
    QTimer *mouseMoveTimer = nullptr;   //老鼠移动定时器
    bool isPress = false;               //按钮是否被按下
    bool mouseIsClicked = false;        //老鼠是否被击打
};

#endif // MYMOUSEBUTTON_H
